<?php
/*
 供channel_show中的ajax使用,用于获取子栏目的id
*/
header("Content-type: text/html; charset=utf-8");
require_once ('config.php');
require_once (WEBURL.'/include/conn.php');
require_once (WEBURL.'/login_status_check.php');
if(!checkLogin()){
	echo "登录超时，请重新登录!";
	exit();
}
 if(empty($_GET['pre_id'])){
 	echo "forbidden";
	exit();
}
class getChildChannelTree{
	private $result;
	private $i;
	private $pre_id;
	function __construct(){
		$this->result=array();
		$this->i=0;
		$this->pre_id=$_GET['pre_id'];
	}
function getChildChannel($channel_id){
	$sql_get_child_channel_id="select channel_id from channel where pre_id=$channel_id;";
	$result_get_child_channel_id=mysql_query($sql_get_child_channel_id);
	if(!$result_get_child_channel_id){
		return;
	}
	$row_number=mysql_num_rows($result_get_child_channel_id);
	if($row_number!=0){
		while($row_get_child_channel_id=mysql_fetch_row($result_get_child_channel_id)){
			$this->result[$this->i++]=$row_get_child_channel_id[0];
			$this->getChildChannel($row_get_child_channel_id[0]);
		}
	}
}
function getAllChildChannel(){
	$this->getChildChannel($this->pre_id);
    if(count($this->result)==0){
			return "";
		}
		return join("|",$this->result);
}
}
$all_child_channel=new getChildChannelTree();
echo($all_child_channel->getAllChildChannel());